using GraphProcessor;
using IQIGame.Onigao.Logic;

namespace IQIGame.Onigao.GamePlay.Editors
{
    [System.Serializable, NodeMenuItem(LevelEditorConst.Execution + "/" + LevelEditorConst.AddHp, typeof(LevelServiceGraph))]
    public partial class LevelServiceExecutionNode_AddHp : LevelServiceExecutionNode
    {
        protected override ServiceExecutionType mServiceType => ServiceExecutionType.AddHp;
        public override string name => LevelEditorConst.AddHp;

        #region property
        [LevelServiceEditorCustomProperty(ServiceExecutionType.AddHp, "目标")]
        public int targetType;
        [LevelServiceEditorCustomProperty(ServiceExecutionType.AddHp, "改变方式")]
        public int addType;
        [LevelServiceEditorCustomProperty(ServiceExecutionType.AddHp, "改变的值(正加负减)")]
        public int addValue;
        [LevelServiceEditorCustomProperty(ServiceExecutionType.AddHp, "是否播放受击动画")]
        public bool isPlayHit;
        #endregion property
        protected override LevelServiceCustomConfig CreateConfig()
        {
            LevelServiceExecutionCustom_AddHp rConfig;
            #region CreateConfig
            rConfig = new LevelServiceExecutionCustom_AddHp
            {
                targetType = this.targetType,
                addType = this.addType,
                addValue = this.addValue,
                isPlayHit = this.isPlayHit
            };
            #endregion CreateConfig
            return rConfig;
        }

        protected override void OnSync(EditorLevelServiceExecutionConfig newConfig, LevelServiceExecutionNode tempNode)
        {
            #region OnSync
            if (tempNode is LevelServiceExecutionNode_AddHp rNode)
            {
                this.targetType = rNode.targetType;
                this.addType = rNode.addType;
                this.addValue = rNode.addValue;
                this.isPlayHit = rNode.isPlayHit;
            }
            #endregion OnSync
        }
    }
}